# Contributor: Maxim Karasev <mxkrsv@disroot.org>
# Maintainer: Maxim Karasev <mxkrsv@disroot.org>
pkgname=endless-sky
pkgver=0.9.16.1
pkgrel=0
pkgdesc="sandbox-style 2D space trading and combat game"
url="https://endless-sky.github.io/"
arch="all !s390x !riscv64" # videogame
license="GPL-3.0-or-later AND CC-BY-SA-4.0 AND CC-BY-SA-3.0 AND CC-BY-3.0"
makedepends="
	glew-dev
	libjpeg-turbo-dev
	libmad-dev
	libpng-dev
	openal-soft-dev
	scons
	sdl2-dev
	"
subpackages="$pkgname-doc"
source="https://github.com/endless-sky/endless-sky/archive/refs/tags/v$pkgver/endless-sky-$pkgver.tar.gz
	install-path.patch"

prepare() {
	default_prepare

	# use the fast lto instead of the slow lto
	sed -i 's|-flto|-flto=auto|g' SConstruct
}

build() {
	# lto fortify-headers
	export CXXFLAGS="$CXXFLAGS -U_FORTIFY_SOURCE"
	scons -j "${JOBS:-2}"
}

check() {
	scons test
}

package() {
	scons DESTDIR="$pkgdir" PREFIX=/usr install
	install -Dm644 copyright "$pkgdir"/usr/share/licenses/$pkgname/copyright
}

sha512sums="
83e0a47160506b1e3608f67534e2dbcf51515d809016efc379448d14331229ffe26360f82cc60c565c84b10c605aec846efc19bcd4af10ee116e5ef8fc804d56  endless-sky-0.9.16.1.tar.gz
91a32aa67cf70a2c6462579cff01aba9d85901675e07c9f296ce03bb34f9dca0f18594c921856ff6c369fe6eb282d9da80148019ebbd7faeecc9231ddec2d57c  install-path.patch
"
